<?php
//error_reporting(0);

/**
 * 默认关注用户推荐管理 
 * 
 * @copyright caijian
 * @since 2012-03-21
 */

include_once($_SERVER["DOCUMENT_ROOT"] . "/core/inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/core/admin.inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/include/foodv2/inc.php");



$g_cgival = array();
$g_pro = array();
$g_show = array();

function show_pro()
{
	global $g_show;
	$smarty = p_get_smarty ();
	$smarty->assign ( $g_show );
	$smarty->display ( "foodv2/user/user_guanzhu.html" );
}


function check_cgi_pro()
{
	global $g_cgival, $g_pro, $g_show;	
}


function get_data()
{
	global $g_cgival, $g_pro, $g_show;
	global $config;

	// 拿到当前站点的site_id
	$site_id = admin::admin_get_user_site_id();
	$admin_id = admin::admin_get_login_uid();
	$admin_name = admin::admin_get_login_user_name();
	

	$db = new db_food_user_offical_user();
	$data = $db->admin_get_food_user_offical_user_by_site_id($site_id);

	$i = 0;
	$muser = new mod_food_user();
	foreach ($data['data'] as $row) {
		if ($i++ <6) {
			$userinfo = $muser->get_weibo_user_info($row['uid']);
			$row['icon'] = $userinfo['profile_image_url'];
			$g_show['data'][] = $row;
		} else {
			$db->admin_update_food_user_offical_user_status($row['uid'], $site_id, 0, 1, $admin_id, $admin_name);
		}
	}

	$g_show['num_tj'] = $i;
}

try
{
	admin_check_login();
// 	admin_check_user_priv("foodv2/main_nav.php");
	
	check_cgi_pro();
	get_data();
}
catch(Exception $e)
{
	$g_show["error"] = 1;
	$g_show["errmsg"] = $e->getMessage();
}

show_pro();
exit;


